'''
Created on 03/03/2009

@author: eh01
'''
import base64
import datetime
import httplib
import unittest


class Test(unittest.TestCase):

    def testPutNewMessage(self):
        username = '' # Put in username here
        password = '' # Put in password here
        base64string = base64.encodestring(
                '%s:%s' % (username, password))[:-1]
        auth_header =  "Basic %s" % base64string
        http_headers = {
             'Authorization':auth_header,
             'Content-Type':'text/xml; charset=utf-8'
             }
        start = datetime.datetime.now()
        print 'Start Request: ' + str(start)
        conn = httplib.HTTPConnection("eplanning-vic-au.appspot.com")        
        conn.request(method="PUT", url='/node/2', body='<Tag1>BLAH5</Tag1>', headers=http_headers)
        response = conn.getresponse()
        if response.status == 302:
            end = datetime.datetime.now()
            print 'End Request: ' + str(end)
            print 'Time taken: ' + str(end - start)
        else:
            self.fail("Should return 302")
        
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testPutMessage']
    unittest.main()